const getAvatar = (comments, users) => {
  // if (comment.children?.length) {
  //   comment.children = comment.children.map((c) => getAvatar(c, users));
  // } else {
  //   const { avatar, name } = users.find((u) => u.id === comment.userID);
  //   return {
  //     ...comment,
  //     avatar,
  //     name,
  //   };
  // }
  return comments.map((com) => {
    console.log(com, 'com');
    if (com.children.length > 0) {
      com.children = getAvatar(com.children, users);
    }
    const { avatar, name } = users.find((u) => u.id === com.userID);
    return {
      ...com,
      avatar,
      name,
    };
  });
};

module.exports = {
  getAvatar,
};
